﻿using Dapper;
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using zzh_the_Visual_Studio.Models;

namespace zzh_the_Visual_Studio.DAL
{
    public class DAL_Students
    {
        private MySqlConnection mySqlConnection = new MySqlConnection(ConfigHelper.Configuration["MySQLConnectionString"]);

        //查询学生姓名、学号
        public List<students> getStudents()
        {
            var list = mySqlConnection.Query<students>("SELECT s_name,s_number FROM students").ToList();
            return list;
        }
        /// <summary>
        /// 这是查询学生个人信息的数据
        /// </summary>
        /// <param name="a">查询个人信息所需要的值</param>
        /// <returns>查询个人信息的数据</returns>
        /// <remarks>by:zzh 2021/12/10</remarks>
        public List<students_classes> getStudent(students_classes a)
        {
            var list = mySqlConnection.Query<students_classes>("SELECT s_name,s_sex,s_phone,s_idcard,s_year,s_number,class_name FROM students_classes where s_number=@s_number", a).ToList();
            return list;
        }
        /// <summary>
        /// 这是查询学生个人成绩的数据
        /// </summary>
        /// <param name="b">查询个人成绩所需要的值</param>
        /// <returns>查询学生个人成绩的数据</returns>
        /// <remarks>by:zzh 2021/12/10</remarks>
        public List<students_scores> getScore(students_scores b)
        {
            var list = mySqlConnection.Query<students_scores>("SELECT s_number,s_name,subject,score,teacher_name FROM students_scores where s_number=@s_number", b).ToList();
            return list;
        }
        //查询学生的详细信息，s_id,姓名，学号，电话，身份证，学年，班级名称，专业名称，二级学院
        //项目前期需要，后期直接利用个人信息
        public List<students_classes> detailStudents()
        {
            var list = mySqlConnection.Query<students_classes>("SELECT * FROM students_classes").ToList();
            return list;
        }
        //查询学生成绩
        public List<students_scores> getScores()
        {
            var list = mySqlConnection.Query<students_scores>("SELECT * FROM students_scores").ToList();
            return list;
        }
    }
}